<template>
	<view class="container">
		<view class="left-bottom-sign"></view>
		<view class="back-btn yticon"></view>
		<view class="right-top-sign"></view>
		<!-- 设置白色背景防止软键盘把下部绝对定位元素顶上来盖住输入框等 -->
		<view class="wrapper">
			<view class="left-top-sign">LOGIN</view>
			<view class="welcome">
				欢迎回来！
			</view>
			<view class="input-content">
				<view class="input-item">
					<text class="tit">账号</text>
					<input 

						v-model="mobile"
						placeholder="请输入账号"
						
						
						
					/>
				</view>
				<view class="input-item">
					<text class="tit">密码</text>
					<input 
						type="password" 
						v-model="pwd"
						placeholder="请输入密码"
						placeholder-class="input-empty"
					
						password 
						data-key="password"
						
						@confirm="loginClick"
					/>
				</view>
			</view>
			<button class="confirm-btn" @click="loginClick" :disabled="logining">登录</button>
			<view class="forget-section"  >
				<text @click="enterpage('../forget/index')">忘记密码?</text>
				
				<text @click="enterpage('../register/index')">马上注册</text>
			</view>
			
		</view>
		<view class="register-section">
			
			
			<checkbox-group @change="radioChange">
				
					<checkbox style="transform: scale(0.5)" value="1" :checked="checkra==='1'" />
				
				
			</checkbox-group>
			
			已阅读并同意<uni-link style="color:#4399fc" href="https://fyapp.huayuyangchu.cn/UserAgreement.html" text="《用户协议》"></uni-link>、<uni-link style="color:#4399fc" href="https://fyapp.huayuyangchu.cn/PrivacyPolicy.html" text="《隐私政策》"></uni-link>
		</view>
		
		
		
		<zwy-popup   :ishide='isshow' width="626rpx" height="330rpx" radius="16rpx">
			<view class="dialog-content">
				<view>请您认真阅读<uni-link style="color:#4399fc" href="https://fyapp.huayuyangchu.cn/UserAgreement.html" text="《用户协议》"></uni-link>、<uni-link style="color:#4399fc" href="https://fyapp.huayuyangchu.cn/PrivacyPolicy.html" text="《隐私政策》"></uni-link>的全部条款，接受后可开始使用我们的服务</view>
			</view>
			<view class="button-log-wrap">
				<view @click="clickaccept(false)" class="no-accept">不同意</view>
				<view @click="clickaccept(true)" class="has-accept">同意</view>
			</view>
		</zwy-popup>
	</view>
</template>

<script>
	
	
	export default{
		data(){
			return {
				isshow:false,
				checkra:'',
				mobile: '',
				pwd: '',
				logining: false
			}
		},
		onLoad(){
			if (process.env.NODE_ENV === 'development') {
			
				this.mobile='19999999999'
				this.pwd='1314521'
				this.checkra=true
			
			}
		},
		methods: {
			onmobileInput(e){
				this.mobile=e.detail.value.replace(/[^\d]/g,'')
				
			},
			radioChange(val){
				this.checkra=val.detail.value[0]
			},
			clickaccept(val){
				this.isshow=false
				this.checkra=val?'1':''
			},
			loginClick(){
				if(!this.checkra){
					this.isshow=true
					return
				}
				
				
				let that=this
				if(this.mobile==''||this.pwd==''){
					uni.showToast({
					    title: '账号密码不能为空',
					    duration:4000,
						icon:'none'
					});
					return
				}
				
				that.apipost('/api/auth/login',{
					mobile:that.mobile,
					pwd:that.pwd
				},true).then(res => {
					if(res.Code==10200){
						uni.setStorageSync("auth_token",res.Data)
						uni.setStorageSync("mobile",that.mobile)
						uni.switchTab({
						    url: '/pages/index/index'
						});
					}
					
				}).catch(err=>{
					console.log(err)
				});
			},
			switchpage(path){
				if(path){
					uni.switchTab({
					    url: '/pages/index/index'
					});
				}else{
					uni.showToast({
					    title: '暂未开放',
					    duration:4000,
						icon:'none'
					});
				}
			},
			enterpage(path){
				
				if(path){
					
					uni.navigateTo({
					    url: path
					});
				}else{
					uni.showToast({
					    title: '暂未开放',
					    duration:4000,
						icon:'none'
					});
				}
			}
			
		},

	}
</script>

<style lang='scss'>
	.button-log-wrap .has-accept{
		border:1rpx solid #409eff;
		background:#409eff;
		color:#fff;
		height:72rpx;
		width:240rpx;
		display:flex;
		justify-content: center;
		align-items: center;
		border-radius: 40rpx;
	}
	.button-log-wrap .no-accept{
		border:1rpx solid #dcdfe6;
		height:72rpx;
		width:240rpx;
		display:flex;
		justify-content: center;
		align-items: center;
		border-radius: 40rpx;
	}
	
	.button-log-wrap{
		display:flex;
		justify-content: space-between;
		align-items: center;
		padding:30rpx 40rpx 0;
	}
	.dialog-content{
		padding:40rpx 30rpx 0;
	}
	.access-content{
		text-align:center;
		padding-top:20rpx;
	}
	.container {
		box-sizing: border-box;
	    padding-top: 115px;
	    position: relative;
	    width: 100vw;
	    height: 100vh;
	    overflow: hidden;
	    background: #fff;
	}
	page{
		background: #fff;
	}
	.container{
		padding-top: 115px;
		position:relative;
		width: 100vw;
		height: 100vh;
		overflow: hidden;
		background: #fff;
	}
	.wrapper{
		position:relative;
		z-index: 90;
		background: #fff;
		padding-bottom: 40rpx;
	}
	.back-btn{
		position:absolute;
		left: 40rpx;
		z-index: 9999;
		padding-top: var(--status-bar-height);
		top: 40rpx;
		font-size: 40rpx;
		color: $font-color-dark;
	}
	.left-top-sign{
		font-size: 120rpx;
		color: $page-color-base;
		position:relative;
		left: -16rpx;
	}
	.right-top-sign{
		position:absolute;
		top: 80rpx;
		right: -30rpx;
		z-index: 95;
		&:before, &:after{
			display:block;
			content:"";
			width: 400rpx;
			height: 80rpx;
			background: #b4f3e2;
		}
		&:before{
			transform: rotate(50deg);
			border-radius: 0 50px 0 0;
		}
		&:after{
			position: absolute;
			right: -198rpx;
			top: 0;
			transform: rotate(-50deg);
			border-radius: 50px 0 0 0;
			/* background: pink; */
		}
	}
	.left-bottom-sign{
		position:absolute;
		left: -270rpx;
		bottom: -320rpx;
		border: 100rpx solid #d0d1fd;
		border-radius: 50%;
		padding: 180rpx;
	}
	.welcome{
		position:relative;
		left: 50rpx;
		top: -90rpx;
		font-size: 46rpx;
		color: #555;
		text-shadow: 1px 0px 1px rgba(0,0,0,.3);
	}
	.input-content{
		padding: 0 60rpx;
	}
	.input-item{
		display:flex;
		flex-direction: column;
		align-items:flex-start;
		justify-content: center;
		padding: 0 30rpx;
		background:$page-color-light;
		height: 120rpx;
		border-radius: 4px;
		margin-bottom: 50rpx;
		&:last-child{
			margin-bottom: 0;
		}
		.tit{
			height: 50rpx;
			line-height: 56rpx;
			font-size: $font-sm+2rpx;
			color: $font-color-base;
		}
		input{
			height: 60rpx;
			font-size: $font-base + 2rpx;
			color: $font-color-dark;
			width: 100%;
		}	
	}

	.confirm-btn{
		width: 630rpx;
		height: 76rpx;
		line-height: 76rpx;
		border-radius: 50px;
		margin-top: 70rpx;
		background: $uni-color-primary;
		color: #fff;
		font-size: $font-lg;
		&:after{
			border-radius: 100px;
		}
	}
	.forget-section{
		display:flex;
		justify-content: space-between;
		font-size: $font-sm+2rpx;
		color: $font-color-spec;
		padding:0 60rpx;
		margin-top: 30rpx;
	}
	.register-section{
		display:flex;
		align-items: center;
		position:absolute;
		left: 0;
		bottom: 50rpx;
		width: 100%;
		font-size: $font-sm+2rpx;
		color: $font-color-base;
		text-align: center;
		text{
			color: $font-color-spec;
			margin-left: 10rpx;
		}
	}
</style>
